/**
 * @param {number} time
 * @param {string} option 
 * @returns {string}
 */
 function formatTime(timestamp) {
	let time = new Date(timestamp).valueOf()
	if (('' + time).length === 10) {
		time = parseInt(time) * 1000
	} else {
		time = +time
	}
	const d = new Date(time)
	// const now = Date.now()

	// const diff = (now - d) / 1000

	// if (diff < 30) {
	// 	return '刚刚'
	// } else if (diff < 3600) {
	// 	// less 1 hour
	// 	return Math.ceil(diff / 60) + '分钟前'
	// } else if (diff < 3600 * 24) {
	// 	return Math.ceil(diff / 3600) + '小时前'
	// } else if (diff < 3600 * 24 * 2) {
	// 	return '昨天'
	// } 
	let nowYear = new Date().getFullYear()
	let paramYear = new Date(timestamp).getFullYear()
	let year = ''
	if (nowYear == paramYear) {
		year = ''
	} else {
		year = paramYear + '-'
	}

	return (
		year +
		(d.getMonth() +
			1) +
		'月' +
		d.getDate() +
		'日 ' +
		d.getHours() +
		':' +
		d.getMinutes()
	)

}
function formatDateTime (dd) {
	const dt = new Date(dd)
	// console.log(dt);
	    const y = dt.getFullYear()
	    const m = (dt.getMonth() + 1 + '').padStart(2, '0')
	    const d = (dt.getDate() + '').padStart(2, '0')
	    const hh = (dt.getHours() + '').padStart(2, '0')
	    const mm = (dt.getMinutes() + '').padStart(2, '0')
	    const ss = (dt.getSeconds() + '').padStart(2, '0')
	    return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
}
export {formatTime,formatDateTime}